import time
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from selenium.webdriver.common.by import By

# 获取Edge浏览器驱动
driver = webdriver.Edge()
# 打开指定网址
driver.get('https://www.baidu.com/')
# 强等2秒
time.sleep(2)
# 窗口最大化
driver.maximize_window()
# 输入框输入内容
# 1.id定位
# search = driver.find_element(By.ID,'kw')
# search.send_keys('贵州1')
# # 2.NAME定位
# driver.find_element(By.NAME,'wd').send_keys('贵州2')
# # 3.TAG_NAME定位
# driver.find_element(By.TAG_NAME,'input').send_keys('贵州3')
# # 4.CLASS_NAME定位
# driver.find_element(By.CLASS_NAME,'s_ipt').send_keys('贵州4')
# # 5.CSS_SELECTOR定位
# driver.find_element(By.CSS_SELECTOR,'.s_ipt').send_keys('贵州5')
# # 6.LINK_TEXT定位
# driver.find_element(By.LINK_TEXT,'新闻').click()
# # 7.PARTIAL_LINK_TEXT定位
# driver.find_element(By.PARTIAL_LINK_TEXT,'新闻').send_keys('贵州7')
# 8.XPATH定位
search = driver.find_element(By.XPATH,'//input[@id="kw" and @NAME="wd"]')
search.send_keys('贵州8')
# 强等2秒
time.sleep(2)
# 回车事件
search.send_keys(Keys.ENTER)
time.sleep(5)
